package com.lyz.dataStructure.JianZhiOffer;/**
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 22:40
 * @Description:
 **/

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2019/6/22 22:40
 *@Description:
 **/

/*
输入一个链表，反转链表后，输出新链表的表头。
 */

 class ListNode {
    int val;
    ListNode next = null;

    ListNode(int val) {
        this.val = val;
    }
}
public class Test19 {
    public ListNode ReverseList(ListNode head) {
        ListNode pre = null;
        ListNode curr = head;
        while(curr!=null){
            ListNode nextNode = curr.next;
            curr.next = pre;
            pre = curr;
            curr = nextNode;
        }
        return pre;
    }
}
